import { http } from "@/utils/http";
import httpConfig from "@/utils/http/httpConfig";

// 角色列表
export function roleLists(params: any) {
  return http.request<any>("get", httpConfig.system + "/role/list", {
    params
  });
}

// 角色列表
export function roleAll(params?: any) {
  return http.request<any>(
    "get",
    httpConfig.system + "/role/optionselect",
    null
  );
}

// 角色列表
export function roleDetail(id: any) {
  return http.request<any>("get", httpConfig.system + "/role/" + id);
}

// 添加角色
export function roleAdd(params: any) {
  return http.request<any>("post", httpConfig.system + "/role", {
    data: params
  });
}
// 编辑角色
export function roleEdit(params: any) {
  return http.request<any>("post", httpConfig.system + "/role/edit", {
    data: params
  });
}
// 删除角色
export function roleDelete(params: any) {
  return http.request<any>("post", httpConfig.system + "/role/del", {
    data: params
  });
}
/**
 * 获取角色已分配的菜单列表
 * @param id
 * @returns
 */
export function roleMenuTreeselect(id: any) {
  return http.request<any>(
    "get",
    httpConfig.system + "/menu/roleMenuTreeselect/" + id
  );
}

export function authMenu(roleId: any, menus: any) {
  return http.request<any>(
    "post",
    httpConfig.system + "/role/authMenu?roleId=" + roleId,
    { data: menus }
  );
}
